using System;
using System.Collections.Generic;
using System.Text;
using Mogre;

namespace com.petiteappli.xenocide.FX
{
    
    


    public class GlowingBillBoard:ITimerUpdatable,IMyMouseListener,IDisposable
    {
        // SceneNode attached to (useful for animation like scaling)
        SceneNode mSceneNode;

        //The internal billboard instance
        Billboard mBillBoard;

        //The internal billboardset
        BillboardSet mBillboardSet;
        // The current scale of the node
        float mNodeScale;
        // The increment of scale
        float mNodeScaleStep;
        // Max value for the scale
        float mNodeMaxScale;
        // Min value for the scale
        float mNodeMinScale;
        // Frequency of anymation;
        float mFrequency;
        // Name
        String mName;
        
        
        public GlowingBillBoard(SceneNode iSceneNode, String iName)
        {
            mNodeMaxScale = 0.8f;
            mName = iName;
            mNodeScale=mNodeMinScale = 0.1f;
            mSceneNode=iSceneNode;
            mSceneNode.InheritScale = false;
            mSceneNode.InheritOrientation = false;
            mSceneNode.Scale(Vector3.UNIT_SCALE * mNodeMinScale);
            mFrequency=4f;
            mNodeScaleStep = (mNodeMaxScale-mNodeMinScale) * mFrequency;

            mBillboardSet = new BillboardSet(mName);//+ "_bbs"
            mBillboardSet.MaterialName = "Alpha/BlueLight";

            mSceneNode.AttachObject(mBillboardSet);
            mBillBoard = mBillboardSet.CreateBillboard(Vector3.ZERO);

            

            
        }
        public bool timerUpdate(float dt)
        {
            mNodeScale += mNodeScaleStep*dt;
            if ((mNodeScale >= mNodeMaxScale) || (mNodeScale <= mNodeMinScale)) mNodeScaleStep = -mNodeScaleStep;
            mSceneNode.SetScale(Vector3.UNIT_SCALE * mNodeScale);
            return true;
        }

        public bool DoMouseUp(Vector3 iPos, MOIS.MouseButtonID button, bool isShift, bool isCtrl, bool isAlt, MyOgreWindow.QueryResult iQr, ISelectable iMO)
        {
            return true;
        }
        public bool DoMouseDown(Vector3 iPos, MOIS.MouseButtonID button, bool isShift, bool isCtrl, bool isAlt, MyOgreWindow.QueryResult iQr, ISelectable iMO)
        {
            return true;
        }

        public void Dispose()
        {
            mBillboardSet.Dispose();
        }


    }
}
